from sqlalchemy import Column, Sequence, ForeignKey
from sqlalchemy.types import Integer, String 
from sqlalchemy.orm import relationship, backref
from __init__ import Base

class Dashboards(Base):

    __tablename__ = "dashboards"

    id = Column(Integer, Sequence('dashboard_id_seq'), primary_key=True)
    title = Column(String(50))
    owner = Column(Integer, ForeignKey('users.id'))
    widgets = relationship('Widgets')
    dashboardgroup = relationship('DashboardGroup')
    #users = relationship("Users", backref=backref('dashboards', order_by=id))

    def __init__(self, title, userid):
        self.title = title
        self.owner = userid

    def __repr__(self):
        return "<Dashboard('%s')>" % self.title
